<template>
    <section>
        <div v-if="yuanYunData[lunarData.yuan + lunarData.yun]" class=" flex justify-center align-center">
            <span>{{ lunarData.yuan }}{{ lunarData.yun }}</span>
        </div>
    </section>
</template>

<script>
import { Solar, SolarUtil, Lunar, LunarYear } from '~/assets/inc/lunar';
import { yuanYunData } from '~/assets/inc/common';
const dateArr = [new Date().getFullYear(), new Date().getMonth() + 1, new Date().getDate()];
export default {
    watch: {
        themeStatus: 'changeThemeHandle',
    },
    data() {
        return {
            yuanYunData,
            themeStatus: false,
            lunarData: {
                star: '',
                date: '',
                description: '',
                doubleYear: false,
                YearGanZhi: '',
                monthGanZhi: '',
                dayInGanZhi: '',
                timeGanZhi: '',
                liuYao: '',
                xiu: '',
                xiuLuck: '',
                xiuSong: '',
                pengzuGan: '',
                pengzuZhi: '',
                yi: '',
                ji: '',
                timeYi: '',
                timeJi: '',
                tao: '',
                yuan: '三元',
                yun: '九运',
                monthDay: '',
                thenDay: 0,
            },
        }
    },
    mounted() {
        this.initDateHandle();
    },
    methods: {
        //选择日期
        checkDateHandler(e) {
            dateArr[2] = e;
            this.initDateHandle();
        },
        //初始化日历
        initDateHandle() {
            const solar = Solar.fromYmd(dateArr[0], dateArr[1], dateArr[2]);
            const lunar = Lunar.fromDate(new Date(dateArr[0], dateArr[1], dateArr[2]));
            const lunarYear = LunarYear.fromYear(dateArr[0]);
            this.lunarData = {
                star: solar.getXingZuo(),
                date: solar.toFullString(),
                description: solar.getLunar().toFullString(),
                doubleYear: SolarUtil.isLeapYear(dateArr[0]),
                YearGanZhi: lunar.getYearInGanZhi(),
                monthGanZhi: lunar.getMonthInGanZhi(),
                dayInGanZhi: lunar.getDayInGanZhi(),
                timeGanZhi: lunar.getTimeInGanZhi(),
                liuYao: lunar.getLiuYao(),
                xiu: lunar.getXiu(),
                xiuLuck: lunar.getXiuLuck(),
                xiuSong: lunar.getXiuSong(),
                pengzuGan: lunar.getPengZuGan(),
                pengzuZhi: lunar.getPengZuZhi(),
                yi: lunar.getDayYi(),
                ji: lunar.getDayYi(),
                timeYi: lunar.getTimeYi(),
                timeJi: lunar.getTimeJi(),
                tao: lunar.getTao(),
                yuan: lunarYear.getYuan(),
                yun: lunarYear.getYun(),
                monthDay: SolarUtil.getDaysOfMonth(dateArr[0], dateArr[1]),
                thenDay: dateArr[2],
            }
        },
        //切换黑白模式
        changeThemeHandle() {
            this.$store.commit('setThemeStatus', this.themeStatus);
            if (this.$store.state.themeStatus) {
                $('html').addClass('blackTheme');
                window.localStorage.setItem('black', true);
            } else {
                $('html').removeClass('blackTheme');
                window.localStorage.removeItem('black');
            }
        },
    }
}
</script>

<style lang="scss" scoped>
@media screen and (min-width:0px) and (max-width:1280px) {}
</style>